#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <string>
#include <arpa/inet.h>

#include <iostream>
using namespace std;

int main()
{
	int sockfd = socket(AF_INET, SOCK_STREAM, 0);	
	struct hostent *server = gethostbyname("localhost");
	
	struct sockaddr_in serv_addr;	
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_port = htons(12534);	
	if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
        cout << "Error connecting" << endl;
		return 1;
	}
	
	int n = write(sockfd,"ping",4);
	
	char buffer[256];
	n = read(sockfd,buffer,255);
	printf("Received: %s\n",buffer);
	
	return 0;
}